import 'package:sow_app_core/sow_app_core.dart';

class MockUserRepository implements UserRepository {
  final RestClient _client;

  MockUserRepository(this._client);
  @override
  Future<String> login(username, password) async => username == 'foo'
      ? throw ServerException("用户信息有误")
      : "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6Ijk4ZTQ5ZDZlLTYyMzUtNGM5Yy05NGJjLTkyMGZlNjk0NWY0YiJ9.npdr0QTAGurx6dRPzW_xTQO1WbU5q0gIJ6AmLT6wbFAMTwdAQ01g464Bk9dm2nCVFvedxqZoBiFUsi8BP_m9-A";

  @override
  Future<String> register(username, password, velCode) async => username ==
          '17612345678'
      ? throw ServerException("新增用户'17612345678'失败，登录账号已存在")
      : 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6Ijk4ZTQ5ZDZlLTYyMzUtNGM5Yy05NGJjLTkyMGZlNjk0NWY0YiJ9.npdr0QTAGurx6dRPzW_xTQO1WbU5q0gIJ6AmLT6wbFAMTwdAQ01g464Bk9dm2nCVFvedxqZoBiFUsi8BP_m9-A';

  @override
  Future<User> info() async => (_client.authorization.isEmpty
      ? throw ServerException("用户信息有误")
      : _client.authorization == '404'
          ? throw UserNotfoundException()
          : User(5, "15959191701", "小说作者", '666'));

  @override
  addFeedback(String params) => 0;

  @override
  changePassword(String oldPass, String newPass) => 0;

  @override
  Future<List<Feedback>> getFeedbackList() async => [];
}
